
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div id="a1" info="它的内容是1*a">2</div>
        <div id="a2" info="它的内容是2*a">4</div>
        <div id="b1" info="它的内容是1*b+1">5</div>
        <div id="b2" info="它的内容是2*b-1">7</div>
    </div>
    <script>
       function updateA1() {
         document.getElementById('a1').innerHTML = obj.a * 1
       }
       function updateA2() {
         document.getElementById('a2').innerHTML = obj.a * 2
       }

       function updateB1() {
        document.getElementById('b1').innerHTML = obj.b * 1 + 1
       }
       function updateB2() {
         document.getElementById('b2').innerHTML = obj.b * 2 - 1
       }
       const eventEnter = {
         "a": [updateA1, updateA2],
         "b": [updateB1, updateB2]
       }
        let obj = new Proxy({
        },{
            get: function (target,key) {
                console.log('getter', target, key)
                return target[key]
            },
            set: function (target, key, val, receiver) {
                console.log('setting', target, key, val, receiver);
                target[key] = val
                eventEnter[key].forEach(fn => fn()) 
            }
        })
        // obj.a = 12
        // let z = obj.b
    </script>
</body>
</html>